<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @cancel="handleCancel"
    :okButtonProps="{ class: { 'jee-hidden': formDisabled } }"
  >
    <template slot="footer">
      <div v-show="isApproval==1">
        <a-button key="back" @click="handleApp(2)"> 驳回 </a-button>
        <a-button key="submit" type="primary" @click="handleApp(1)"> 通过 </a-button>
      </div>
      <div v-show="isApproval==2">
        <a-button key="formDisabled" @click="handleCancel"> 关闭 </a-button>
        <a-button key="submit" type="primary" @click="handleApp(3)"> 下线 </a-button>
      </div>
      <div v-show="isApproval==3">
        <a-button key="formDisabled" @click="handleCancel"> 关闭 </a-button>
        <a-button key="submit" type="primary" v-show="title!=='详情'" @click="handleOk"> 确定 </a-button>

      </div>
      <!-- <div v-show="!formDisabled">
        <a-button key="formDisabled" @click="handleCancel"> 关闭 </a-button>
        <a-button key="submit" type="primary" @click="handleOk"> 确定 </a-button>
      </div> -->
    </template>
    <order-list ref="orderList" v-if="isShow" :teamLeaderData="shopownerId" :isTeamLeader="true"></order-list>
    <shop-info-form ref="realForm" @ok="submitCallback" :title='title' :disabled="formDisabled" v-if="!isShow"></shop-info-form>
  </j-modal>
</template>

<script>
import OrderList from '@/views/orderlist/OrderList'
import ShopInfoForm from './ShopInfoForm'


export default {
  name: 'ShopInfoModal',
  components: {
    ShopInfoForm,
    OrderList,
  },
  data() {
    return {
      title: '',
      shopownerId: '',
      width: 1024,
      visible: false,
      disableSubmit: false,
      isShow: false,
    }
  },
  computed: {
    formDisabled() {
      return this.disableSubmit
    },
    isApproval() {
      if (this.title=='上线') {
        return 1
      }
      if (this.title=='下线') {
        return 2
      }
      if (this.title=='详情'||this.title=='查看') {
        return 3
      }
    },
  },
  methods: {
    handleApp(val) {
      this.$refs.realForm.handleApp(val,this.record.id)
    },
    add() {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.add()
      })
    },
    edit(record) {
      this.visible = true
      this.record = record
      this.$nextTick(() => {
        this.$refs.realForm.edit(record)
        this.isShow = false
      })
    },
    view(record) {
      this.visible = true
      this.shopownerId = record.shopownerId
      this.$nextTick(() => {
        this.isShow = true
      })
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.isShow = false
    },
    handleOk() {
      this.$refs.realForm.submitForm()
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
  },
}
</script>